﻿using MeetAI.Model.DTO;
using MeetAI.Service.IService;
using MeetAI.Utility;
using Nancy;
using Nancy.ModelBinding;

namespace MeetAI.API.Modules
{
    public class classTypeModule : NancyModule
    {
        private readonly IDy_ClassType_Service IDy_ClassType_Service;
        public classTypeModule(IDy_ClassType_Service IDy_ClassType_Service) : base("/v1/class/type")
        {
            this.IDy_ClassType_Service = IDy_ClassType_Service;
            //获取分类列表
            Get["", true] = async (param, token) =>
            {
                var dto = this.Bind<dy_classtype_dto>();
                Result res = new Result();
                if (string.IsNullOrWhiteSpace(dto.molds) || !dto.pid.HasValue)
                {
                    res.code = ResultType.fail;
                    res.message = "参数错误";
                    return Response.AsJson(res);
                }
                res.data = await IDy_ClassType_Service.getClassTypeList(dto);
                return Response.AsJson(res);
            };
        }
    }
}